package com.pro.configs;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
 * Description: swagger3配置   不配置也可以访问swagger
 * <p>
 * Author: wilson
 * <p>
 * Date: 2024/1/15 13:57
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

  @Bean
  public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo())
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.pro.controller"))
        .paths(PathSelectors.any())
        .build()
        .enable(true) // 配置是否开启,生产环境需要关闭
        ;
  }

  public ApiInfo apiInfo() {
    return new ApiInfoBuilder()
        .title("xxx应用")
        .description("xxx应用的接口用例")
        .termsOfServiceUrl("https://www.baidu.com/")
        .version("1.0")
        .build();
  }

}


